/*
 * Copyright Aristool AG Switzerland
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at 
 * 
 * http://www.apache.org/licenses/LICENSE-2.0 
 * 
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 * See the License for the specific language governing permissions and 
 * limitations under the License.
 */
package org.opprua.tidy.conversion;

import java.math.BigDecimal;

/**
 * TODO: add Java doc
 * 
 * Prepared for first commit: 15.07.2007
 * 
 * @author Lin Li
 */
class CTDouble extends ChangeType<Double> {

  private static SingleChanger<Double>[] changers = null;

  public CTDouble() {
    super(Double.class, 0.0);
  }

  @Override
  @SuppressWarnings("unchecked")
  public SingleChanger<Double>[] getchangers() {
    if (changers == null) {
      changers = (SingleChanger<Double>[]) new SingleChanger[] {
                  new SingleChanger<Double>(String.class) {

                    public Double change(Object data) {
                      return Double.parseDouble((String) data);
                    }
                  }, new SingleChanger<Double>(Float.class) {

                    public Double change(Object data) {
                      return ((Float) data).doubleValue();
                    }
                  }, new SingleChanger<Double>(BigDecimal.class) {

                    public Double change(Object data) {
                      return ((BigDecimal) data).doubleValue();
                    }
                  }, new SingleChanger<Double>(Integer.class) {

                    public Double change(Object data) {
                      return ((Integer) data).doubleValue();
                    }
                  }, new SingleChanger<Double>(Long.class) {

                    public Double change(Object data) {
                      return ((Long) data).doubleValue();
                    }
                  } };
    }
    return changers;
  }
}